goog.provide('czk.ui.grid.Row');

goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.math');

goog.require('czk.ui.ZKComponent');

/**
 * @constructor
 * @extends {czk.ui.ZKComponent}
 */
czk.ui.grid.Row = function() {
  goog.base(this);
};
goog.inherits(czk.ui.grid.Row, czk.ui.ZKComponent);

czk.ui.grid.Row.prototype.td = null;

czk.ui.grid.Row.prototype.createDom = function() {
  var dh = this.getDomHelper();
  var trStyle = null;
  if (this.position == 0) {
    trStyle = 'first';
  } else if (goog.math.modulo(this.position, 2) == 0)
    trStyle = 'odd';
  else
    trStyle = 'even';
  var el = dh.createDom(goog.dom.TagName.TR, {
    'className': trStyle
  });

  this.setElementInternal(el);
};

czk.ui.grid.Row.prototype.addChild = function(child, opt_render) {
  // new td for each child
  var dh = this.getDomHelper();
  this.td = dh.createDom(goog.dom.TagName.TD, {
    'className': 'defaultGroup'
  });
  goog.dom.insertChildAt(this.getElement(), this.td);

  goog.base(this, 'addChild', child, opt_render);

};

czk.ui.grid.Row.prototype.getContentElement = function() {
  return this.td;
};

czk.ui.grid.Row.create = function() {
  return new czk.ui.grid.Row();
};
